﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microformats.Controls;
using System.Web.UI;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace Microformats.Controls
{
    public class CalendarGeo : CalendarProperty
    {
        public CalendarGeo()
        {
            ClassName = "geo";
        }

        [Browsable(true)]
        [Category("Calendar Parameter")]
        [Description("Specifies the coordinate properties.")]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public Collection<Coordinate> Coordinates
        {
            get;
            set;
        }

        public void Render(ref HtmlTextWriter writer)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Class, ClassName);
            writer.RenderBeginTag(HtmlTag);

            foreach (Coordinate coordinate in Coordinates)
            {
                if (coordinate is Latitude)
                {
                    Latitude latitude = coordinate as Latitude;
                    latitude.Render(ref writer);
                }
                else if (coordinate is Longitude)
                {
                    Longitude longitude = coordinate as Longitude;
                    longitude.Render(ref writer);
                }
            }

            writer.RenderEndTag();
        }
    }
}
